/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package microblog.requirement;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import network.Config;
import network.DataPreparation;

/**
 *
 * @author Administrator
 */
public class cRequirement {

    public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {

        DataPreparation data = new DataPreparation();
        Map<String, Integer> tagCount = new HashMap<String, Integer>();
        Map<String, Integer> tagLargeCount = new HashMap<String, Integer>();
        List<String> ids = data.data.mFIDs;
        ids.remove("0");
        ids.remove(Config.uid);
        int friendCount = ids.size();
        int biFriendCount = data.data.mBiFIDs.size();
        int biFriendFame = 0;
        int fameCount = 0;
        int zoombieCount = 0;
        int agencyCount = 0;
        int mediaCount = 0;
        int normalCount = 0;
        System.out.println("用户名 关注情况 用户分类");
        for (String id : ids) {
            System.out.print(data.data.username.get(id) + " ");
            if (data.data.mBiFIDs.contains(id)) {
                System.out.print("互粉 ");
            } else {
                System.out.print("单向 ");
            }
            if (data.data.fameIDandTag.containsKey(id)) {
                String[] tags = data.data.fameIDandTag.get(id).split(" ");
                System.out.print("名人：" + data.data.fameIDandTag.get(id) + "\r\n");
                fameCount += 1;
                for (String s : tags) {
                    int newcount = 1;
                    if (tagCount.containsKey(s)) {
                        newcount = tagCount.get(s) + 1;
                    }
                    tagCount.put(s, newcount);
                }
                if (data.data.mBiFIDs.contains(id)) {
                    biFriendFame += 1;
                }
            } else if (data.data.mediaIDs.contains(id)) {
                System.out.print("媒体\r\n");
                mediaCount += 1;
            } else if (data.data.agencyIDs.contains(id)) {
                System.out.print("机构\r\n");
                agencyCount += 1;
            } else if (data.data.zoombieIDs.contains(id)) {
                System.out.print("营销用户\r\n");
                zoombieCount += 1;
            } else {
                System.out.print("普通用户\r\n");
                normalCount += 1;
            }
        }
        System.out.println("互粉个数 " + biFriendCount + " " + (double) biFriendCount / (double) friendCount + "");
        System.out.println("互粉中名人个数 " + biFriendFame + " " + (double) biFriendFame / (double) biFriendCount + "");
        System.out.println("名人个数 " + fameCount + " " + (double) fameCount / (double) friendCount + "");
        System.out.println("机构个数 " + agencyCount + " " + (double) agencyCount / (double) friendCount + "");
        System.out.println("媒体个数 " + mediaCount + " " + (double) mediaCount / (double) friendCount + "");
        System.out.println("营销用户个数 " + zoombieCount + " " + (double) zoombieCount / (double) friendCount + "");
        System.out.println("普通用户个数 " + normalCount + " " + (double) normalCount / (double) friendCount + "");
        Set keys = tagCount.keySet();
        int count = keys.size();
        System.out.println("================================");
        for (int i = 0; i < count; i++) {
            String key = (String) keys.toArray()[i];
            String[] bigCategory = key.split("/");
            int largeCount = tagCount.get(key);
            if (tagLargeCount.containsKey(bigCategory[0])) {
                largeCount = tagLargeCount.get(bigCategory[0]) + tagCount.get(key);
            }
            tagLargeCount.put(bigCategory[0], largeCount);
            System.out.println(key + " " + tagCount.get(key));
        }
        keys = tagLargeCount.keySet();
        count = keys.size();
        int allTagCount=0;
        System.out.println("================================");
        for (int i = 0; i < count; i++) {
            String key = (String) keys.toArray()[i];
            allTagCount+=tagLargeCount.get(key);
        }
        for (int i = 0; i < count; i++) {
            String key = (String) keys.toArray()[i];
            System.out.println(key + " " + tagLargeCount.get(key)+" "+(double)tagLargeCount.get(key)/(double)allTagCount);
        }
    }
}
